package cn.edu.cqupt.cxcy.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.cqupt.cxcy.dto.AdminImpl;
import cn.edu.cqupt.cxcy.model.Team;
import cn.edu.cqupt.cxcy.util.JsonUtil;
import cn.edu.cqupt.cxcy.util.Tools;

public class AdminDelTeam extends HttpServlet{
private static final long serialVersionUID = 1L;
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}
	
	/**
	 * 管理添加团队的登录名、密码、用户名
	 */
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String message="";
		boolean success=false;
		Tools tool=new Tools();
		
		if (request.getParameter("te_id").equals("")||request.getParameter("te_id").equals("null")){
			message="未知错误";
			
		}
		else {
			boolean res=new AdminImpl().delTeam(Integer.parseInt(request.getParameter("te_id")));
			if (res){
				message="删除成功！";
				success=true;
				
				}
				else {
					message="未知错误";
				}
		}
		JsonUtil json = new JsonUtil(); 
		json.put("success", success);
		json.put("message", message);
		//boolean res=new AdminImpl().addTeam(team);
		response.setContentType("application/json;charset=utf-8");
		response.setHeader("pragma","no-cache");
		response.setHeader("cache-control","no-cache");
		PrintWriter out = response.getWriter();
		out.print(json);
		out.flush();
		out.close();
			
		
	}
	

}
